package com.oracle.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.oracle.mapper.TeacherMapper;
import com.oracle.pojo.Teacher;
import com.oracle.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;


@Service
public class TeacherServiceImpl implements TeacherService {


    @Autowired
    private TeacherMapper teacherMapper;

    @Override
    @Transactional(readOnly = false, propagation = Propagation.REQUIRED)
    public int updataTeacher(Teacher teacher) {
        Integer teachId = teacher.getTeachId();
        QueryWrapper<Teacher> teacherQueryWrapper = new QueryWrapper<>();
        teacherQueryWrapper.eq("teach_Id",teachId);
        int update = teacherMapper.update(teacher, teacherQueryWrapper);
        return update   ;
    }

//    @Override
//    @Transactional(readOnly = true ,propagation = Propagation.SUPPORTS)
//    public boolean findTeacher(String teachNum, String teachPwd) {
//        QueryWrapper<Teacher> queryWrapper = new QueryWrapper<>();
//        queryWrapper.eq("teach_Num", teachNum).eq("teach_Pwd", teachPwd);//主要这里要和数据库的字段名一致
//        Teacher teacher = teacherMapper.selectOne(queryWrapper);
//
//        return teacher != null;
//    }
}
